#include<iostream>
using namespace std;
const int N = 1010;
int win[N], lose[N], use[N];
long long dp[N];
int n, x;
int main()
{
	cin >> n >> x;
	for (int i = 1; i < n + 1; i++) {
		cin >> lose[i] >> win[i] >> use[i];
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = x; j >= use[i]; j--) {
			dp[j] = max(dp[j] + lose[i], dp[j - use[i]] + win[i]);
		}
		for (int j = use[i] - 1; j >= 0; j--) {
			dp[j] += lose[i];
		}
	}
	cout << dp[x]*5 << endl;
	return 0;
}
//int main()
//{
//	cin >> n >> x;
//	for (int i = 1; i <= n; i++) {
//		cin >> lose[i] >> win[i] >> use[i];
//	}
//	for (int i = 1; i <= n; i++) {
//		for (int j = 0; j <= x; j++) {
//			if (j >= use[i]) {
//				dp[i][j] = max(dp[i - 1][j] + lose[i],
//					dp[i - 1][j - use[i]] + win[i]);
//			}
//			else {
//				dp[i][j] += lose[i];
//			}
//		}
//	}
//	cout << dp[n][x]*5 << endl;
//	return 0;
//}	